<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <style>
        .red{
            color: red;
        }
        .blue{
            color: blue;
        }
    </style>
</head>
<body>
    <div id="root">
        <!-- 使用三元表达式改变颜色 -->
        <h1 :class="isRed ? 'red' : 'blue'">三元</h1>
        <!-- 使用对象方式 -->
        <h1 :class="{red : true , blue: isRed}">对象</h1>
        <!-- 使用数组 -->
        <h1 :class="['red','blue']">数组</h1>
        <button @click="changeColor">点我改颜色</button>
        <!-- 使用对象给样式赋值 -->
        <h1 :style="{fontSize: fontSize + 'px'}">样式</h1>
        <button @click="changeFontSize(+6)">点我放大字体</button>
        <button @click="changeFontSize(-6)">点我缩小字体</button>
    </div>
    
    <script src="../js/vue.js"></script>
    <script>
        new Vue({
            el: '#root',
            data: {
                isRed: true,
                fontSize: 20
            },
            methods: {
                changeColor(){
                    this.isRed = !this.isRed
                },
                changeFontSize(vaule){
                    this.fontSize = this.fontSize + vaule
                }
            }
            
        })
    </script>
</body>
</html>